<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/style.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/cn.js"></script>

<!--colorbox-->
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/jquery.colorbox.js"></script>
<link href="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/colorbox2.css" rel="stylesheet" type="text/css"/>
</head>

<body>
	<div id="main">
		<div id="navigation">当前位置：<a href="<?php echo $this->projectUrl(array('action'=>'index'));?>">主协议列表</a> &gt; <a href="<?php echo $this->projectUrl(array('action'=>'main-event','mainVersion'=>$this->vars['mainVersion']));?>">[<?php echo $this->vars['mainVersion'];?>]事件列表</a> &gt;<a href="<?php echo $this->projectUrl(array('action'=>'main-field-loop','mainVersion'=>$this->vars['mainVersion'],'eventId'=>$this->vars['eventId'],'fieldSort'=>$this->vars['fieldSort']));?>">[<?php echo $this->vars['eventId'];?>]循环列表</a>&gt;<span id="focus">添加</span></div>
		<div id="body">
			<div id="edit">
				<form id="editForm" name="editForm" method="post" action="">
					<table class="table">
						<tr>
							<td colspan="2">*为必填项</td>
						</tr>
						<tr>
							<td width="20%">主协议版本号：</td>
							<td>
								<?php echo $this->vars['mainVersion'];?>
								<input name="mainVersion" type="hidden"id="mainVersion" value="<?php echo $this->vars['mainVersion'];?>" />
							</td>
						</tr>
						<tr>
							<td width="20%">事件Id：</td>
							<td>
								<?php echo $this->vars['eventId'];?>
								<input name="eventId" type="hidden" id="eventId" value="<?php echo $this->vars['eventId'];?>"/>
							</td>
						</tr>
						<tr>
							<td width="20%">事件的字段序号：</td>
							<td>
								<?php echo $this->vars['fieldSort'];?>
								<input name="fieldSort" type="hidden" id="fieldSort" value="<?php echo $this->vars['fieldSort'];?>"/>
							</td>
						</tr>
						<tr>
							<td width="20%">循环的字段序号：</td>
							<td>
								<input name="loopFieldSort" type="text" class="validate[callback[checkLoopFieldSort,1]] input" id="loopFieldSort" value="<?php echo $this->maxSort;?>" size="30" style="width:300px;" /> * 
							</td>
						</tr>
						<tr>
							<td width="20%">字段名称：</td>
							<td>
								<input name="fieldName" type="text" class="validate[required] input" id="fieldName" value="" size="30" style="width:300px;" /> * 
							</td>
						</tr>
						<tr>
							<td width="20%">字段类型：</td>
							<td>
								<select name="fieldType" id="fieldType">
								<?php foreach($this->fieldTypeRows as $row) {
								          if (!in_array($row['code'],array('A','C','E','N','K','P','F','G'))){
								?>
								<option value="<?php echo $row['code'];?>"><?php echo $row['nameNote'];?></option>
								<?php 
								       }
								   }?>
								</select> 
								<a href="javascript:void(0);" onclick="$(document).ready(function(){$.fn.colorbox({href:'<?php echo $this->projectUrl(array('controller'=>'act-md-main', 'action'=>'field-type'));?>?'+Math.random()});});">对照</a>
							</td>
						</tr>
						<tr>
							<td width="20%">实现方式：</td>
							<td>
								<input name="complyMode" type="radio" class="type" value="0" /> SDK
								<input name="complyMode" type="radio" class="type" value="1" checked="checked"  /> APP
							</td>
						</tr>
						<tr>
							<td width="20%">说明：</td>
							<td><textarea name="note" cols="30" rows="5" class="input" id="note" style="width:300px;"></textarea></td>
						</tr>
						<tr>
							<td width="20%">备注：</td>
							<td><textarea name="remark" cols="30" rows="5" class="input" id="remark" style="width:300px;"></textarea></td>
						</tr>
						<tr>
							<td width="20%">&nbsp;</td>
							<td><input type="submit" name="button" id="button" value="提交" class="button"/></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>

<script language="javascript">
function checkLoopFieldSort(account)
{
    var url = '<?php echo $this->projectUrl(array('action'=>'get-event-field-loop-is-exists-by-json','mainVersion'=>$this->vars['mainVersion'],'eventId'=>$this->vars['eventId'],'fieldSort'=>$this->vars['fieldSort'], 'account'=>'{account}'), NULL, false);?>'+'?rand/' + Math.random();
	url = url.replace('{account}', account);
	checkResult = {'isRight':true, 'message':''};
	
	if ($.trim($("#loopFieldSort").val()) == '') {
		return checkResult = {'isRight':false, 'message':'循环的字段序号。'};
	}
	if (account != '') {
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			async: false,
			success: function(data){
				if (data == 1) {
					checkResult = {'isRight':false, 'message':'* 事件[<?php echo $this->vars['eventId'];?>]字段序号[<?php echo $this->vars['fieldSort'];?>]的循环类型的字段序号已存在，请换一个。'};
				}
			} 
		}); 
	}
	return checkResult;
}

$("#editForm").submit(function(){
	return true;
});
</script>
</body>
</html>